package org.example.service.impl;

import org.example.mapper.RoleMapper;
import org.example.pojo.*;
import org.example.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    RoleMapper roleMapper;

    @Override
    public List<Role> selectRoles() {
        return roleMapper.selectRoles();
    }


    @Override
    public RoleRes selectRoleRes(int id) {
        return roleMapper.selectRoleRes(id);
    }

    @Override
    public Role selectByName(String rName) {
        return roleMapper.selectByName(rName);
    }

    @Override
    public int deleteRes(int rId) {
        return roleMapper.deleteRes(rId);
    }

    @Override
    public int insertRes(int rId, int resId) {
        return roleMapper.insertRes(rId,resId);
    }

    public ResId selectResId(String resName){
        return  roleMapper.selectResId(resName);
    };

    @Override
    public ResPojo getParRes(int resId) {
        return roleMapper.getParRes(resId);
    }

    @Override
    public List<ResPojo> showChildResouce(int resId) {
        return roleMapper.showChildResouce(resId);
    }

    @Override
    public ResRolePojo selectResRolePojo(int rId) {
        return roleMapper.selectResRolePojo(rId);
    }

    @Override
    public int addRole(EditRole editRole) {
        return roleMapper.addRole(editRole);
    }

    @Override
    public List<Role> selectVariablesByAll(String var) {
        return roleMapper.selectVariablesByAll(var);
    }

    public int updateRolePwd(Role role){

        return roleMapper.updateRolePwd(role);
    }

    @Override
    public int deleteRole(int rId) {
        return roleMapper.deleteRole(rId);
    }
}
